package com.yd.app.service.pc.OldsRetrieveService;

import com.yd.app.mapper.OldsRetrieveMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.Old;
import com.yd.domain.searchParam.OldParam;
import com.yd.domain.commom.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author zy
 * @create 2018-03-08 10:26
 * @desc 旧物管理
 **/
@Service
public class OldsRetrieveService extends BaseService{
    @Autowired
    private OldsRetrieveMapper oldsRetrieveMapper;
    /**
     * @Author: zy
     * @Desc: 录入旧物回收信息
     * @Date:  2018/3/8
     * @Param
     */
    public void addOld(Old o){
        oldsRetrieveMapper.addOld(o);
    }
    /**
     * @Author: zy
     * @Desc:分页检索旧物消息数据
     * @Date:  2018/3/8
     */
    public PageModel getOldList(OldParam oldParam, int pageIndex, int pageSize){
        PageModel pm=new PageModel();
        List<Old> list=new ArrayList<>();
        list=oldsRetrieveMapper.searchOldList(oldParam,getStartRow(pageIndex,pageSize),pageSize);
        int count=0;
        if(pageIndex==1){
            //查询总条数
            count=oldsRetrieveMapper.searchOldCount(oldParam);
            pm.setCount(count);
        }
        pm.setList(list);
        return pm;
    }

    /**
     * 查询商品
     * @param id
     * @return
     */
    public Old getOldById(String id) {
        Old old=oldsRetrieveMapper.getOldById(id);
        return old;
    }
    /**
     * @Author: zy
     * @Desc: 修改旧物消息数据
     * @Date:  2018/3/8
     */
    public void updateOld(Old o) {
        oldsRetrieveMapper.updateOld(o);
    }
    /**
     * @Author: zy
     * @Desc: 删除数据
     * @Date:  2018/3/8
     * @Param
     */
    public void deleteOld(String id) {
        oldsRetrieveMapper.deleteOld(id);
    }
    /**
     * @Author: zy
     * @Desc: 修改旧物状态:审核 ,并且设置价格等
     * 审核人、审核时间
     * @Date:  2018/3/8
     * @Param
     */
    public void updateStaus(Old o){
        oldsRetrieveMapper.updateStaus(o);
    }
    /**
     * @Author: zy
     * @Desc:交易状态、交易时间、最终价格
     * @Date:  2018/3/8
     * @Param
     */
    public void updateDealStaus(Old o){
        oldsRetrieveMapper.updateDealStaus(o);
    }

    /**
     * 审核旧物
     * @param oldId
     */
    public void updateOldkStatus(String oldId, String checkUser, Date checkTime, String checkStatus) {
        oldsRetrieveMapper.updateOldStatus(oldId,checkUser,checkTime,checkStatus);
    }

    /**
     * 旧物估价
     * @param old
     */
    public void assessOld(Old old) {
        oldsRetrieveMapper.assessOld(old);
    }

    /**
     * 旧物交易状态
     * @param oldId
     */
    public void updateDealStatus(String oldId,Date checkTime, String dealStatus) {
        oldsRetrieveMapper.updateDealStatus(oldId,checkTime,dealStatus);
    }

    /**
     * 删除图片
     * @param id
     */
    public void updateIconUrl(String id) {
        oldsRetrieveMapper.updateIconUrl(id);
    }
}
